import request from '@/service'

// 发布活动
export function publishEvent(eventInfo: any) {
  return request.post({
    url: '/event',
    data: eventInfo
  })
}

// 编辑活动
export function editEvent(event_id: number, eventInfo: any) {
  return request.put({
    url: `/event/${event_id}`,
    data: eventInfo
  })
}

// 删除活动
export function deleteEvent(event_id: number) {
  return request.delete({
    url: `/event/${event_id}`
  })
}

// 查询活动
export function searchEvent(queryInfo: any) {
  return request.get({
    url: '/event',
    params: {
      ...queryInfo
    }
  })
}

// 修改活动状态
export function updateEventStatus(event_id: number, status: string) {
  return request.put({
    url: `/event/${event_id}/status`,
    params: {
      status
    }
  })
}

// 根据id查询活动
export function searchEventById(event_id: number) {
  return request.get({
    url: `/event/${event_id}`
  })
}

// 根据id查询参与的人
export function searchJoinUser(event_id: number) {
  return request.get({
    url: `/event/${event_id}/member`
  })
}

// 取消报名
export function cancelRegister(event_id: number, user_id: number) {
  return request.post({
    url: `/event/${event_id}/member/${user_id}/cancel`
  })
}

// 查询每个社团的活动个数
export function searchPublishEventCount() {
  return request.get({
    url: `/event/club/count`
  })
}
